Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: allow removing a pointer from a field #7518

Conversation

cjbland
Copy link
Contributor

@cjbland cjbland commented Aug 24, 2021

New Pull Request Checklist

Issue Description

Creates a new field on the pointer type to allow removing (unlink) an object from a pointer field.

Related issue: #7517

Approach

TODOs before merging

  • Add test cases
  • Add entry to changelog
  • Add changes to documentation (guides, repository pages, in-code descriptions)
  • Add security check

@codecov
Copy link

codecov bot commented Aug 24, 2021

Codecov Report

Merging #7518 (cea7c62) into master (12eb6c8) will decrease coverage by 0.05%.
The diff coverage is 100.00%.

❗ Current head cea7c62 differs from pull request most recent head 4ab49b7. Consider uploading reports for the commit 4ab49b7 to get more accurate results
Impacted file tree graph

@@            Coverage Diff             @@
##           master    #7518      +/-   ##
==========================================
- Coverage   93.97%   93.92%   -0.06%     
==========================================
  Files         181      181              
  Lines       13354    13275      -79     
==========================================
- Hits        12550    12468      -82     
- Misses        804      807       +3     
Impacted Files Coverage Δ
src/GraphQL/loaders/parseClassTypes.js 94.23% <ø> (ø)
src/GraphQL/transformers/mutation.js 93.61% <100.00%> (+0.13%) ⬆️
src/batch.js 91.37% <0.00%> (-1.73%) ⬇️
src/Adapters/Files/GridFSBucketAdapter.js 79.50% <0.00%> (-0.82%) ⬇️
src/Security/CheckGroups/CheckGroupServerConfig.js 95.23% <0.00%> (-0.42%) ⬇️
src/triggers.js 94.95% <0.00%> (-0.41%) ⬇️
src/Controllers/LiveQueryController.js 96.42% <0.00%> (-0.35%) ⬇️
src/Adapters/Storage/Mongo/MongoStorageAdapter.js 92.37% <0.00%> (-0.32%) ⬇️
src/GraphQL/ParseGraphQLSchema.js 96.96% <0.00%> (-0.23%) ⬇️
src/LiveQuery/ParseLiveQueryServer.js 95.50% <0.00%> (-0.19%) ⬇️
... and 14 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 12eb6c8...4ab49b7. Read the comment docs.

@mtrezza
Copy link
Member

mtrezza commented Aug 24, 2021

Thanks for this PR!

Please make sure to check the "I'm not disclosing a vulnerability" box in the template and keep in mind that if you encounter any vulnerability to not discuss or include it as part of this PR.

@cjbland
Copy link
Contributor Author

cjbland commented Aug 24, 2021

Will do, I also plan on updating the documentation, I just ran out of time yesterday. I will add it in today.

@mtrezza
Copy link
Member

mtrezza commented Aug 24, 2021

Great! Let us know if you need any guidance.

@cjbland
Copy link
Contributor Author

cjbland commented Aug 26, 2021

I checked in the CHANGELOG.md changes and I've forked the docs so I can add documentation on how to interact with objects in GraphQL. Please let me know if there is anything else you need from me for this PR.

Copy link
Member

@Moumouls Moumouls left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use op delete

src/GraphQL/transformers/mutation.js Outdated Show resolved Hide resolved
@mtrezza
Copy link
Member

mtrezza commented Oct 14, 2021

@cjbland could you take a look at this PR? it would be great if we could get this ready for merge.

@parse-github-assistant
Copy link

The label type:improvement cannot be used here.

@cjbland
Copy link
Contributor Author

cjbland commented Oct 16, 2021

Just pushed some changes, let me know if that's what you're looking for.

@mtrezza mtrezza changed the title #7517: Allow removing a pointer from a field feature: allow removing a pointer from a field Oct 16, 2021
@parse-github-assistant
Copy link

parse-github-assistant bot commented Oct 16, 2021

Thanks for opening this pull request!

  • 🎉 We are excited about your hands-on contribution!

@mtrezza mtrezza changed the title feature: allow removing a pointer from a field feat: allow removing a pointer from a field Oct 16, 2021
CHANGELOG.md Outdated Show resolved Hide resolved
@mtrezza mtrezza requested a review from Moumouls October 17, 2021 19:13
Copy link
Member

@Moumouls Moumouls left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@mtrezza
Copy link
Member

mtrezza commented Oct 18, 2021

@cjbland could you look at the failing tests?

@cjbland
Copy link
Contributor Author

cjbland commented Oct 18, 2021

Yes, sure thing; give me a couple of days to circle back to it.

Copy link
Member

@Moumouls Moumouls left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cjbland @mtrezza here i think we have a deeper issue on the whole GraphQL API. My team also start to encounter many issues with the current implementation of aField: null on the the GraphQL API.

I think we need here to convert on the graphql layer all null to {__op: "Delete"}, since null in the database will not resolve on {aField: { exists: false}}.

We have the same null handling issue, on File, Pointer and all other field. Currently developers using the GraphQL API do not have any solution (without cloud code) to completly unset a filed from the Parse Object.

I'll push a PR that convert all null value on mutation to {__op: "Delete"}

Also the null to opDelete implementation will be easier for developers to use and will avoid new interfaces like unlink on File. Pointer and all other fields.

PS: Currently my team need to write some cloud code functions to correctly convert null to undefined, via request.object.unset("aField"), it looks like tedious, hard to maintain and expose the developer to weird bugs if some fields are not checked in the cloud function.

@Moumouls
Copy link
Member

Moumouls commented Oct 19, 2021

@mtrezza based on my comment #7518 (review)

I'll suggest to close this PR and i'll push a global fix for the whole graphqh API.

Issue: #7648

@mtrezza
Copy link
Member

mtrezza commented Oct 19, 2021

I'll push a PR that convert all null value on mutation to {__op: "Delete"}

A null value is not the same as undefined and a database usually differentiates between null values and non-existent fields. For example, in the JS SDK, there is a distinction between obj.set("key", null); and obj.unset("key");. Not allowing this distinction in the GraphQL endpoint means that GraphQL would behave differently than other Parse SDKs and setting a field to null would produce a result that is different from what a developer expects. I think the approach in your previous comment makes more sense. Also see parse-community/parse-dashboard#1721 (comment).

Looking at the GraphQL spec it seems you are correct.

@Moumouls
Copy link
Member

Moumouls commented Oct 19, 2021

Here i can suggest to close this one since #7649 was opened

@mtrezza ok for you ?

@mtrezza
Copy link
Member

mtrezza commented Oct 19, 2021

@cjbland does the approach in #7649 work for your use case?

@Moumouls
Copy link
Member

Moumouls commented Oct 19, 2021

@mtrezza i added the test that cover the use case of @cjbland on my PR to support pointer removal.

@mtrezza
Copy link
Member

mtrezza commented Nov 18, 2021

Thanks @Moumouls so I'm closing this in favor of #7649.

@mtrezza mtrezza closed this Nov 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants